package com.softserve.academy.food.model;

import com.softserve.academy.food.entity.eDish;

public class mDish 
{
	private int id;
	private String name;
	private String description;
	private int price;
	private String image;
	private int type;
	private int weight;
	
	public mDish()
	{
	}
	
	public mDish( int id )
	{
		this.id = id;
	}
	
	public mDish(String name, String description, int price, int type)
	{
		this.name = name;
		this.price = price;
		this.description = description;
		this.type = type;
	}
	
	public mDish( eDish dish )
	{
		id = dish.getId();
		name = dish.getName();
		setPrice( dish.getPrice() );
		description = dish.getDescription();
		type = dish.getType();
		weight = dish.getWeight();
		image = dish.getImage();
	}

	public int getId() 
	{
		return id;
	}

	public void setId(int id) 
	{
		this.id = id;
	}

	public String getName() 
	{
		return name;
	}

	public void setName( String name ) 
	{
		this.name = name;
	}

	public String getDescription() 
	{
		return description;
	}

	public void setDescription( String description ) 
	{
		this.description = description;
	}

	public float getPrice() 
	{
		float floatPrice = price;
		return floatPrice/100;
	}

	public void setPrice( float price ) 
	{
		this.price = (int)price*100;
	}

	public String getImage() 
	{
		return image;
	}

	public void setImage( String image ) 
	{
		this.image = image;
	}

	public int getType() 
	{
		return type;
	}

	public void setType( int type ) 
	{
		this.type = type;
	}

	public int getWeight() 
	{
		return weight;
	}

	public void setWeight( int weight ) 
	{
		this.weight = weight;
	}

	@Override
	public int hashCode() 
	{
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((description == null) ? 0 : description.hashCode());
		result = prime * result + id;
		result = prime * result + ((image == null) ? 0 : image.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + price;
		result = prime * result + type;
		result = prime * result + weight;
		return result;
	}

	@Override
	public boolean equals(Object obj) 
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof mDish))
			return false;
		mDish other = (mDish) obj;
		if (description == null) 
		{
			if (other.description != null)
				return false;
		} 
		else if (!description.equals(other.description))
			return false;
		if (id != other.id)
			return false;
		if (image == null) 
		{
			if (other.image != null)
				return false;
		} 
		else if (!image.equals(other.image))
			return false;
		if (name == null) 
		{
			if (other.name != null)
				return false;
		} 
		else if (!name.equals(other.name))
			return false;
		if (price != other.price)
			return false;
		if (type != other.type)
			return false;
		if (weight != other.weight)
			return false;
		return true;
	}

	@Override
	public String toString() 
	{
		return "Dish [id=" + id + ", name=" + name + ", description="
				+ description + ", price=" + price + ", image=" + image
				+ ", type=" + type + ", weight=" + weight + "]";
	}

}
